package ac.svn.accesscontrol.ui.helper.formatter;

import ac.svn.accesscontrol.store.SVNGroup;
import ac.svn.accesscontrol.store.SVNLocation;
import ac.svn.accesscontrol.store.SVNUser;
import ac.svn.accesscontrol.ui.IListItemTextFormatter;

public class ItemTypeTextFormatter implements IListItemTextFormatter {

	@Override
	public String formatString(Object msgObj) {
		String toString = "";
		if(null != msgObj)
		{
			if(msgObj instanceof SVNUser)
			{
				SVNUser svnUser = (SVNUser) msgObj;
				toString = String.format("<HTML>[<b>User<b>]%s",svnUser.getUserName());
			}
			else if(msgObj instanceof SVNGroup)
			{
				SVNGroup svnGroup = (SVNGroup) msgObj;
				toString = String.format("<HTML>[<b>Group<b>]%s",svnGroup.getGroupName());
			}
			else if(msgObj instanceof SVNLocation)
			{
				SVNLocation location = (SVNLocation) msgObj;
				toString = String.format("<HTML>[<b>Location<b>]%s",location.getLocationPath());
			}
		}
		return toString;
	}

	@Override
	public String formatToolTip(Object msgObject) {
		return formatString(msgObject);
	}

}
